package nl.windgazer.arachne.services.facebook;

import org.apache.tapestry5.json.JSONObject;
import org.joda.time.DateTime;

/**
 * Expected to use a JSONObject filled with the following:
 * {
 *    "id": "525556615",
 *    "name": "Martin Reurings",
 *    "first_name": "Martin",
 *    "last_name": "Reurings",
 *    "link": "http://www.facebook.com/windgazer",
 *    "username": "windgazer",
 *    "gender": "male",
 *    "locale": "en_GB"
 * }
 * @return
 */
public class FacebookUserImp implements FacebookUser {

	private JSONObject details;

	private Long timestamp;

	public FacebookUserImp(JSONObject resultSet) {
		this.details = resultSet;
		timestamp = new DateTime().getMillis();
	}

	public String getName() {
		return details.getString("name");
	}

	public String getFirstName() {
		return details.getString("first_name");
	}

	public String getLastName() {
		return details.getString("last_name");
	}

	public String getUID() {
		return details.getString("id");
	}

	public void setLastVerified(Long millis) {
		this.timestamp = millis;
	}

	public void setLastVerified(DateTime date) {
		this.timestamp = date.getMillis();
	}

	public Long getLastVerified() {
		return timestamp;
	}

}
